package com.ys.otms.controller;

import com.ys.otms.services.IYLShipsServices;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by Administrator on 2018/10/12.
 */
@Controller
@RequestMapping("/ylships")
public class YLShipsController {

    private static Logger logger = LoggerFactory.getLogger(YLShipsController.class);
    @Autowired
    private IYLShipsServices iylShipsServices;

    /**
     *船舶与运力分类绑定
     * @param request
     * @return
     * @throws Exception
     */
    @RequestMapping("/insertIYLShipsQuery")
    @ResponseBody
    public JSONObject insertIYLShipsQuery(HttpServletRequest request) throws Exception{
        logger.info("YLShipsController insertIYLShipsQuery start");
        JSONObject jsonYLShips = new JSONObject();
        try {
            jsonYLShips = iylShipsServices.insertIYLShipsQuery(request);
        } catch (Exception e) {
            logger.error("YLShipsController insertIYLShipsQuery Exception",e);
            jsonYLShips.put("SUCCESS",false);
            jsonYLShips.put("MSG","新增数据失败！");
        }
        return jsonYLShips;
    }

    /**
     * 删除船舶与运力分类绑定
     * @param request
     * @return
     */
    @RequestMapping("/deleteIYLShips")
    @ResponseBody
    public JSONObject deleteIYLShips(HttpServletRequest request) throws Exception {
        logger.info("YLShipsController deleteIYLShips start");
        JSONObject jsonYLShips = new JSONObject();
        try {
            jsonYLShips = iylShipsServices.deleteIYLShips(request);
        } catch (Exception e) {
            logger.error("YLShipsController deleteIYLShips error", e);
            jsonYLShips.put("SUCCESS",false);
            jsonYLShips.put("MSG","删除失败！");
        }
        return jsonYLShips;
    }
}
